package com.jin.lazytool.listener;

import com.github.kwhat.jnativehook.keyboard.SwingKeyAdapter;
import com.jin.lazytool.JinTaskController;
import com.jin.lazytool.entity.KeyPressEvent;
import com.jin.lazytool.entity.KeyReleasedEvent;
import com.jin.lazytool.utils.CurrentStateUtil;

import java.awt.event.KeyEvent;

public class KeyboardListener extends SwingKeyAdapter {


     @Override
    public void keyTyped(KeyEvent keyEvent) {
        super.keyTyped(keyEvent);
    }
    @Override
    public void keyPressed(KeyEvent keyEvent) {
        if(JinTaskController.collectingFlag){
            CurrentStateUtil.addEventOfGroup(new KeyPressEvent(keyEvent));
        }
    }
    @Override
    public void keyReleased(KeyEvent keyEvent) {
        if(JinTaskController.collectingFlag) {
            CurrentStateUtil.addEventOfGroup(new KeyReleasedEvent(keyEvent));
        }
    }
}
